/**
 * Created by waiwai on 17-8-3.
 */
const rules = {
  mobileTel: /^1\d{10}$/,
  nickName: /^[\w\u4e00-\u9fa5\uf900-\ufa2d()（）-]*$/,
  amount: /^(0|[1-9]\d{0,11})(\.\d{0,2})?$/,
  email: /^([\w-\\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/,
}

module.exports = {
  customValidators: {
    isMobile(value) {
      return rules.mobileTel.test(value)
    },
    isSame(value, other) {
      return value === other
    },
    isEmail(value) {
      return rules.email.test(value)
    },
    isEqual(value, code) {
      console.log(value, code, value === code, '比较值是否相同')
      return value === code
    },
    isTooShort(value, num) {
      return value.length >= num
    },
    isArray(value) {
      return Array.isArray(value)
    },
    gte(param, num) {
      return param >= num
    },
  },
}
